<?php
	echo "<h2 id='contentTitle'>".$pageTitle."</h2>";
	echo $this->renderElement('message');

	echo '<div> Adicione Videos do YouTube a sua lista.<br><br> </div>';
	$addButton = "<span class=\"buttonAdd\">Adicionar Video</span>";
	echo html_entity_decode($html->link($addButton, '/videos/add/',array('class'=>'button')));

	if (isset($video) && is_array($video) && (!empty($video))) {
		echo "<br />";
		echo "<table>";

		/* CabeÃ§alho */
		echo "<thead>";
		echo "<div></div>";
		echo "<tr class='tableHeader'>";
		echo "<th class='tableHeaderBegin'>Nome</th>";
		echo "<th class='tableHeaderMiddle'>Descrição</th>";
		echo "<th class='tableHeaderMiddle'>Editar</th>";
		echo "<th class='tableHeaderEnd'>Excluir</th>";
		echo "</tr>";
		echo "</thead>";

		/* RodapÃ© */
		echo "<tfoot>";
		echo "<tr class='tableFooter'>
		<td colspan='100%'></td>
		</tr>";
		echo "</tfoot>";

		$i=0;
		foreach ($video as $video) {
			if (($i++ % 2) == 1) $zebrado = " class='oddTr' ";
			else $zebrado = "";
			echo "<tr ".$zebrado.">";
			
			if (strlen($video['Video']['name']) >= 20) {
				$aux1 = substr($video['Video']['name'],0, 20)."...";
			} else {
				$aux1 = $video['Video']['name'];
			}
			
			if (strlen($video['Video']['description']) >= 30) {
				$aux2 = substr($video['Video']['description'],0, 30)."...";
			} else {
				$aux2 = $video['Video']['description'];
			}
			
			echo "<td class='tdCenter'>".$html->link($aux1, '/videos/view/'.$video['Video']['id'])."</td>";
			echo "<td class='tdCenter'>".$html->link($aux2, '/videos/view/'.$video['Video']['id'])."</td>";
			echo "<td class='tdCenter'>".html_entity_decode($html->link($html->image('fileedit.png',array('class'=>'icon')), '/videos/edit/'.$video['Video']['id']))."</td>";
			echo "<td class='tdCenter'>".html_entity_decode($html->link($html->image('filedel.png',array('class'=>'icon')), '/videos/delete/'.$video['Video']['id'], array(), 'Confirma a exclusão deste item?'))."</td>";
			echo "</tr>";
		}
		echo "</table>";
	} else {
		echo "<p>Não há Videos em sua Lista.</p>";
	}
